<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>万州特色农产品网</title>


<include file="./Tpl/default/Index/header.html" />

<script type="text/javascript" src="__PUBLIC__/js/shopping.js"></script>
<link href="__PUBLIC__/css/base.css" type="text/css" rel="stylesheet" />
<link href="__PUBLIC__/css/main.css" type="text/css" rel="stylesheet" />

<style>
/*demo css*/
.i_tips {
	height: 30px;
	margin-left: 20px;
	color: #f60;
	font-size: 14px;
	line-height: 30px
}

.i_box {
	margin: 10px 20px;
	font-size: 14px;
	float: left
}

.i_box * {
	vertical-align: middle
}

.i_box a {
	padding: 2px 5px;
	background-color: #e9e9e9;
	border: 1px solid #ccc;
	text-decoration: none;
	color: #585858;
	line-height: 20px
}

.i_box a:hover {
	color: #000
}

.i_box input {
	width: 30px;
	height: 18px;
	margin: 0 8px;
	padding: 2px;
	border: 1px solid #ccc;
	text-align: center;
	line-height: 16px
}
</style>

</head>
<body>



<div class="w980 clear mT10 p20">
<p class="font18 fontYH line24 lineB w90auto pTB5 mB20"><span class="mainbg block fLeft" style="background-position:-425px -120px; width:26px;height:25px;margin-right:3px;"></span>我的购物车<span class="font12 fontnormal mL10"><a href="__URL__/deleteShoppingCart">×清空购物车</a></span></p>
<form action="__URL__/shoppingOrder" method="post">
<table border="0" class="w90auto lineBorder" cellpadding="5" cellspacing="1">
<tbody>
	<tr>
		<th class="p10 white" bgcolor="#777777">序号</th>
		<th class="p10 white" bgcolor="#777777">商品</th>
		<th class="p10 white" bgcolor="#777777">名称</th>
		
		<th class="p10 white" bgcolor="#777777">单价</th>
		<th class="p10 white" bgcolor="#777777">数量</th>
		<th class="p10 white" bgcolor="#777777">小计</th>
		<th class="p10 white" bgcolor="#777777">操作</th>
	</tr>
	
	
	<volist id="vo" name="list" key="k">
    
		<tr >
								
	    	<td valign="middle" align="center" class="p10"><input type="hidden" style="float:left;width:2px;" name="andy[]" value="{$vo['id']}" /><span ><label id="number{$k}">{$vo['id']}</label></span></td>			
			<td valign="middle" align="center" class="p10"><a href ="__APP__/ProductDetail/index/id/{$vo['product_id']}" target="_blank"><img width="100" height="100" class="p1 lineBorder" src="__PUBLIC__/uploadfiles/files/common/{$vo['imageurl_small']}"></a></td>
			<td valign="middle" class="p10"><a href ="__APP__/ProductDetail/index/id/{$vo['product_id']}" target="_blank" class="orange">{$vo['name']}</a></td>
			
			<td valign="middle" align="center" class="p10"><span id="price{$k}">{$vo['local_price']}</span></td>			
			<td valign="middle" align="center" class="p10"><a href="javascript:;" class="J_minus">-</a>
			<input readonly="readonly" type="text" id="quantity{$k}" value="{$vo['quantity']}" class="J_input"  style="width:60px;"/><a href="javascript:;"
			class="J_add">+</a>（{$vo['pro_unit_name']}）</td>
			<td valign="middle" align="center" class="p10"><span id="lumpsum{$k}">{$vo['lumpsum']}</span></td>
			<td valign="middle" align="center" class="p10"><a href="__URL__/deleteShoppingCart/id/{$vo['id']}" class="orange">删除</a></td>
		</tr>
	</volist>
<tr>
<td colspan="8" class="p10 lineB lineT" align="right">产品数量总计：<span class="orange" id="productcount"></span> 件 产品金额总计：￥<span class="orange" id='totle'></span></td>
</tr>
<!-- 产品数量总计 -->
<input type="hidden" name="productcount" id="productcount_id"/>

<!-- 产品金额总计 -->
<input type="hidden" name="totlecount" id="totle_id"/>

<tr>
<td colspan="8" class="p10 " align="right"><a href="#" onclick="window.history.go(-1);" class="p5 orange mR10">&laquo;&nbsp;继续购物</a><input class="p5 bgOrange white border-s-Orange mR10" style="cursor:pointer;border:0;" border="0" type="submit" value="&nbsp;去结算&nbsp; "/> </td>
</tr>
</tbody>
</table>


</form></div>

<include file="./Tpl/default/Index/footer.html" />

		<script language="JavaScript">
			//调用			
			
			//js 保留两位小数
			Number.prototype.toFixed=function(len){
                if (isNaN(len) || len == null) {
                    len = 0;
                }
                else {
                    if (len < 0) {
                        len = 0;
                    }
                }
                return Math.round(this * Math.pow(10, len)) / Math.pow(10, len);
            }
			
			function kkk(){
				//console.log((jQuery('span label')));				
				$("span label").each(function(i,n){					
					alert($(this).html()) ;										
				});				
				window.location = "__URL__/shoppingOrder";
			}
			
			
			$(document).ready(function(){
				//总计
				var l = "lumpsum" ;
				//单价
				var p = "price" ;
				//数量
				var q = "quantity" ;
				//序号
				var n = "number" ;

				var tempPrice = 0 ;
				//alert( {$shoppingCount['count']});
				for ( var i = 1 ; i <= "{$shoppingCount}" ; i++){
					//alert('3');					
					$('#lumpsum'+i).html(  parseFloat($('#price'+i).html() * $('#quantity'+i).val()).toFixed(2) );					
					tempPrice = parseFloat(tempPrice) + parseFloat($('#lumpsum'+i).html())
				}
				//初始化购物车时对总价进行初始化
				
				$('#totle').html(' '+tempPrice);
				$('#productcount').html(' '+"{$shoppingCount}");
				//隐藏参数设值
				
				$('#totle_id').val($('#totle').html()) ;
				$('#productcount_id').val($('#productcount').html()) ;
				
			  	$('.i_box').iVaryVal({
				  	Fun:function(){			  	
					//alert('3');	
					//alert("{$shoppingCount}");
					//$('#lumpsum').html(  $('#price').html() * $('#quantity').val() );
					var j = $GLOBAL.index + 1 ;					
					$('#lumpsum'+j).html(  parseFloat($('#price'+j).html() * $('#quantity'+j).val()).toFixed(2) );					
					var adjusttempPrice = $('#lumpsum'+j).html();
					var tempadjustPrice = 0 ;
					for ( var i = 1 ; i <= "{$shoppingCount}" ; i++){
						tempadjustPrice = tempadjustPrice + parseFloat($('#lumpsum'+i).html());
					}

					
					$('#totle').html(' '+tempadjustPrice);
					$('#totle_id').val($('#totle').html()) ;					
					//ajax调用
					$.post('__URL__/updateShoppingCart',
				    	    {	
					    	    'id':document.getElementById(n+j).innerHTML,
					    	    'quantity':document.getElementById(q+j).value,
					    	    'lumpsum':document.getElementById(l+j).innerHTML			    	    		    		
					    	},
							    function(data){											
							    },
					'json');
					
				}});	
			});

		</script>

</body>
</html>